﻿using System.Collections;

using System.Collections.Generic;
using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgents.Sensors;
using Unity.MLAgents.Actuators;

public class FlightAgentVector : FlightAgent
{
    public override void CollectObservations(VectorSensor sensor)
    {
        /*
        // The absolute position observation implementation
        // Target and Agent positions
        sensor.AddObservation(plygrndCtrler.target.localPosition);
        sensor.AddObservation(airplane.transform.localPosition);
        
        // Agent velocity
        sensor.AddObservation(airplane.rBody.velocity);
        //sensor.AddObservation(airplane.rBody.angularVelocity);
        
        // BadSphere position
        // assert that badSpheres number = 4
        sensor.AddObservation(plygrndCtrler.badSpheres[0].transform.localPosition);
        sensor.AddObservation(plygrndCtrler.badSpheres[1].transform.localPosition);
        sensor.AddObservation(plygrndCtrler.badSpheres[2].transform.localPosition);
        sensor.AddObservation(plygrndCtrler.badSpheres[3].transform.localPosition);
        */

        // The relative position observation implementation
        // Target positions
        Vector3 targetPosR = airplane.transform.InverseTransformPoint(plygrndCtrler.target.position);
        sensor.AddObservation(targetPosR);
        
        // Agent velocity
        sensor.AddObservation(airplane.rBody.velocity);
        sensor.AddObservation(airplane.rBody.angularVelocity);

        // BadSphere position
        // assert that badSpheres number = 4
        Vector3 badSpherePosR;
        for(int i=0;i<4;i++)
        {
            badSpherePosR = airplane.transform.InverseTransformPoint(plygrndCtrler.badSpheres[i].transform.position);
            sensor.AddObservation(badSpherePosR);
        }
        
    }
}